from PyQt6.QtWidgets import QMessageBox

from PIL import Image
from utils.error import getError


def show_image(win):
    path = win.ui.lineEdit.text()
    if not path:
        QMessageBox.warning(win, "参数错误", f"[输出文件|文件名]不能为空，请输入正确的图片路径！")
        return
    try:
        image = Image.open(path)  # 打开图片
        image.show()  # 显示图片
    except:
        getError()  # 获取异常信息
        QMessageBox.warning(win, "路径错误", f"{path}路径错误，请输入正确的图片路径！")